package com.qing.fordemo;

public class ForDemo {
    public static void main(String[] args) {
        //死循环
        // for (; ; ) {
        // }
        // ForDemo.zeroToOneHundredOddEvenSum();
        // ForDemo.zeroToKiloDivideFive();
        ForDemo.nineMultiplyNine();

    }

    //计算0-100之间奇数和偶数的和
    public static void zeroToOneHundredOddEvenSum() {
        int oddSum = 0;
        int evenSum = 0;
        for (int i = 0; i <= 100; i++) {
            //i余(模)2 = 0，代表偶数
            if (i % 2 == 0) {
                oddSum += i;
            } else {
                evenSum += i;
            }
        }
        System.out.println("奇数和为：" + oddSum + "偶数和为：" + evenSum);
    }

    //找出0-1000能被5除的整数，并且每行输出三个
    public static void zeroToKiloDivideFive() {
        for (int i = 1; i <= 1000; i++) {
            if (i % 5 == 0) {
                System.out.print(i + "\t");
            }
            if (i % (5 * 3) == 0) {
                System.out.println();
            }
        }
    }

    //99乘法表
    public static void nineMultiplyNine() {
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(i + "*" + j + "=" + i * j + "\t");
            }
            System.out.println();
        }
    }
}
